package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

class zajr {
   private zoz a = null;
   private Workbook b = null;
   private zcfk c = null;
   private static final com.aspose.cells.b.c.a.za d = new com.aspose.cells.b.c.a.za(new String[]{"lnStyleLst", "fillStyleLst"});

   zajr(zoz var1, String var2) {
      this.a = var1;
      this.b = var1.a;
   }

   zajr(Workbook var1, String var2) {
      this.b = var1;
   }

   void a(zcfk var1, boolean var2) throws Exception {
      this.c = var1;
      this.a();
      if (var2) {
         this.b.c.b = var1.c();
      }

   }

   private void a() throws Exception {
      if (this.c.d_() != null && "http://schemas.openxmlformats.org/drawingml/2006/3/main".equals(this.c.d_().b("xmlns")) && this.b.b != null) {
         this.b.b.e = true;
      }

      zcfl var1 = zase.b((zcfq)this.c.d_(), "themeElements");
      if (var1 != null) {
         Iterator var2 = var1.j().iterator();

         while(var2.hasNext()) {
            Object var3 = var2.next();
            if (var3 instanceof zcfl) {
               zcfl var4 = (zcfl)var3;
               String var5 = var4.g;
               if ("clrScheme".equals(var5)) {
                  this.d(var4);
               } else if ("fontScheme".equals(var5)) {
                  this.b(var4);
               } else if ("fmtScheme".equals(var5)) {
                  this.a(var4);
               }
            }
         }

      }
   }

   private void a(zcfl var1) throws Exception {
      try {
         HashMap var2 = new HashMap();
         zaja var3 = new zaja(this.b, var2);
         zcfw var4 = new zcfw(var1.b(), false);
         var4.j();

         while(zass.a(var4)) {
            switch(d.a(var4.p())) {
            case 0:
               this.a(var3, var4);
               break;
            case 1:
               var4.a();
               break;
            default:
               var4.a();
            }
         }
      } catch (Exception var5) {
         ;
      }

   }

   private void a(zaja var1, zcfw var2) throws Exception {
      if (var2.n()) {
         var2.a();
      } else {
         var2.d();

         while(zass.a(var2)) {
            if ("ln".equals(var2.p())) {
               Line var3 = new Line(this.b, this.b.c);
               com.aspose.cells.b.a.a.ze.a(this.b.c.a(), (Object)var3);
               var1.a(var2, var3);
            } else {
               var2.a();
            }
         }

      }
   }

   private void b(zcfl var1) {
      zcfl var2 = zase.b((zcfq)var1, "majorFont");
      if (var2 != null) {
         this.b.c.f.b = this.c(var2);
      }

      zcfl var3 = zase.b((zcfq)var1, "minorFont");
      if (var3 != null) {
         this.b.c.f.c = this.c(var3);
      }

   }

   private zop c(zcfl var1) {
      zop var2 = new zop();
      Iterator var3 = var1.j().iterator();

      while(var3.hasNext()) {
         Object var4 = var3.next();
         if (var4 instanceof zcfl) {
            zcfl var5 = (zcfl)var4;
            String var6 = var5.g;
            String var7;
            if ("latin".equals(var6)) {
               var7 = zase.a((zcfq)var5, (String)"typeface");
               if (var7 != null && !"".equals(var7)) {
                  var2.a = var7;
               }
            } else if ("ea".equals(var6)) {
               var7 = zase.a((zcfq)var5, (String)"typeface");
               if (var7 != null && !"".equals(var7)) {
                  var2.b = var7;
               }
            } else if ("cs".equals(var6)) {
               var7 = zase.a((zcfq)var5, (String)"typeface");
               if (var7 != null && !"".equals(var7)) {
                  var2.c = var7;
               }
            } else if ("font".equals(var6)) {
               var7 = zase.a((zcfq)var5, (String)"script");
               String var8 = zase.a((zcfq)var5, (String)"typeface");
               if (var7 != null && var8 != null) {
                  int var9 = this.b.c.f.a(var7);
                  if (var9 != -1) {
                     var2.d.put(var9, var8);
                  }
               }
            }
         }
      }

      return var2;
   }

   private void d(zcfl var1) {
      this.b.c.a = zase.a((zcfq)var1, (String)"name");
      zcfs var2 = var1.j();

      for(int var3 = 0; var3 < var2.a(); ++var3) {
         zcfq var4 = var2.a(var3);
         if (var4 instanceof zcfl) {
            zns var5 = this.e((zcfl)var4);
            if (var5 != null) {
               int var6 = zase.ah(var5.b);
               this.b.c.e[var6] = var5;
            }
         }
      }

   }

   private zns e(zcfl var1) {
      zns var2 = new zns();
      var2.a(Color.getEmpty());
      zcfs var3 = var1.j();

      for(int var4 = 0; var4 < var3.a(); ++var4) {
         if (var3.a(var4) instanceof zcfl) {
            zcfl var5 = (zcfl)var3.a(var4);
            String var6 = null;
            zcfg var7;
            if ("sysClr".equals(var5.g)) {
               var7 = zass.a(var5, "lastClr");
               if (var7 != null) {
                  var6 = var7.h;
               }

               zcfg var8 = zass.a(var5, "val");
               if (var8 != null) {
                  var2.c = var8.h;
                  if (var6 == null) {
                     if ("window".equals(var8.h)) {
                        var6 = "ffffff";
                     } else {
                        var6 = "000000";
                     }
                  }
               }

               var2.a(true);
            }

            if ("srgbClr".equals(var5.g)) {
               var7 = zass.a(var5, "val");
               if (var7 != null) {
                  var6 = var7.h;
               }

               ArrayList var11 = new ArrayList();
               Iterator var9 = var5.e().iterator();

               while(var9.hasNext()) {
                  zcfg var10 = (zcfg)var9.next();
                  if (!"val".equals(var10.i())) {
                     com.aspose.cells.b.a.a.ze.a(var11, (Object)(new znm(var10.i(), var10.h)));
                  }
               }

               if (var11.size() > 0) {
                  var2.d.a(4, var11);
               }
            }

            if (var6 != null) {
               var2.a = zase.t(var6);
            }
            break;
         }
      }

      var2.b = var1.g;
      return com.aspose.cells.a.c.zh.a(var2.a()) ? null : var2;
   }
}
